home *** CD-ROM | disk | FTP | other *** search
- #include<hold/anim.h>
-
- /* 000 */ void bubble_control(void);
- /* 001 */ void bubble(int [], int);
-
- /* 002 */ void bubble_control(){
- /* 003 */ int d[10] = {10,9,8,7,6,5,4,3,2,1};
- /* 004 */ int parts = 10;
- a_func("bubble_control",2);
- a_irayini(d,"d",parts,3);
- a_intini(parts,"parts",4);
- a_show(5);
-
- /* 005 */ bubble(d,parts);
- a_endfunc("bubble_control",6);
- /* 006 */ }
-
- /* 007 */ void bubble(int a[], int N){
- /* 008 */ int i,j,t;
-
- a_func("bubble",7);
- a_iraypas("a",7);
- a_intini(N,"N",7);
- a_intini(i,"i",8);
- a_intini(j,"j",8);
- a_intini(t,"t",8);
- a_intass("i","N",9);
- a_intcomp("i>=1",9);
- /* 009 */ for(i=N;i>=1;i--){
- a_intass("j","1",10);
- a_intcomp("j<i",10);
- /* 010 */ for(j=1;j<i;j++){
- a_intcomp("a[j-1] > a[j]",11);
- /* 011 */ if(a[j-1] > a[j]){
- /* 012 */ t = a[j-1];
- a_intass("t","a[j-1]",12);
- /* 013 */ a[j-1] = a[j];
- a_intass("a[j-1]","a[j]",13);
- /* 014 */ a[j] = t;
- a_intass("a[j]","t",14);
- /* 015 */ }
- a_intass("j","j+1",10);
- a_intcomp("j<i",10);
- /* 016 */ }
- a_intass("i","i-1",9);
- a_intcomp("i>=1",9);
- /* 017 */ }
- a_endfunc("bubble",18);
- /* 018 */ }
-